<?php

/*
 * Class Template Grafik
 * =====================
 * Class ini berfungsi untuk membuat template untuk output grafik.
 */

class GrafikTemplate extends Application {

    private $mIsSettingGrafik = true;
    private $mTitle;
    private $mSubtitle;
    private $mXAxisDataVerticalAlignment = false;
    private $mXAxisDataArray;

    /* ===== *//* ===== *//* ===== *//* ===== *//* ===== *//* ===== *//* ===== */


    /* ===== *//* ===== *//* ===== *//* ===== *//* ===== *//* ===== *//* ===== */
    /*                            O U T P U T                                  */
    /* ===== *//* ===== *//* ===== *//* ===== *//* ===== *//* ===== *//* ===== */

    public function PrintGrafik() {
        $tPrint = "";

        //TITLE
        if ($this->mTitle)
            $tPrint.= "<h1>" . $this->mTitle . "</h1>";
        ////
        //SUBTITLE
        if ($this->mSubtitle)
            $tPrint.= "<h2>" . $this->mSubtitle . "</h2>";
        ////
        //SETTING GRAFIK FORM
        if ($this->mIsSettingGrafik === true) {
            $tPrint.="<div id=\"SettingGrafik-Container\">\n" .
                    "\t<form class=\"chartConfiguratorThingy\">\n" .
                    "\t\t<div class=\"fieldGroup\">\n" .
                    "\t\t\t<fieldset>\n" .
                    "\t\t\t<legend><b>Konfigurasi Grafik:</b></legend>" .
                    "\t\t\t<div class=\"fieldGroup\">" .
                    "\t\t\t\t<label for=\"width\">Lebar:</label>" .
                    "\t\t\t\t<input type=\"text\" name=\"width\" id=\"SettingGrafik-Width\" value=\"\" disabled=\"true\" />" .
                    "\t\t\t\t<span class=\"CheckBox\"><input type=\"checkbox\" id=\"SettingGrafik-DefaultCheckbox\" checked=\"true\" /> Default</span>" .
                    "\t\t\t</div>" .
                    "\t\t\t</fieldset>" .
                    "\t\t</div>" .
                    "\t</form>".
                    "</div>" ;
        }
        ////
        //SETTING X-AXIS DATA
        if (is_array($this->mXAxisDataArray) && count($this->mXAxisDataArray) > 0) {
            foreach ($this->mXAxisDataArray as $tValue) {
                $tPrint.= "<th><div class=\"XAxis-Caption\">";
                
                if($this->mXAxisDataVerticalAlignment)
                    $tPrint.="<div class=\"Vertical\">" . $tValue. "</div>";
                else
                    $tPrint.= $tValue;

                $tPrint.= "</div></th>";
            }
        } else {
            $tData = false;
            echo "<i>-- an error ocurred. X-Axis Data may have be an array data type --</i>";
        }
        
        
        //OUTPUT
        echo $tPrint;
    }

    /* ===== *//* ===== *//* ===== *//* ===== *//* ===== *//* ===== *//* ===== */
    /*                          M U T U A T O R                                */
    /* ===== *//* ===== *//* ===== *//* ===== *//* ===== *//* ===== *//* ===== */

    public function SetSettingGrafik($pBool) {
        $this->mIsSettingGrafik = $pBool;
    }

    public function SetTitle($pTitle) {
        $this->mTitle = $pTitle;
    }

    public function SetSubtitle($pTitle) {
        $this->mSubtitle = $pTitle;
    }

    public function SetXAxisDataVerticalAlignment($pBool) {
        $this->mXAxisDataVerticalAlignment = $pBool;
    }

    public function SetXAxisData($pArrayData) {
        if (is_array($pArrayData) && count($pArrayData) > 0) {
            $this->mXAxisDataArray = $pArrayData;
        } else {
            echo "<i>-- an error ocurred. X-Axis Data may have be an array data type --</i>";
        }
    }

}

?>
